package com.nageoffer.shortlink.admin.util;

import java.security.SecureRandom;

/**
 * ClassName: RandomGenerator
 * Package: com.nageoffer.shortlink.admin.util
 * Description:
 *
 * @Author Jetson
 * @Create 2024/10/15 21:39
 * @Version 1.0
 */
public final class RandomGenerator {
    private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    private static final int LENGTH = 6;
    private static final SecureRandom random = new SecureRandom();

    public static String generateRandomString() {
        StringBuilder result = new StringBuilder(LENGTH);
        for (int i = 0; i < LENGTH; i++) {
            int index = random.nextInt(CHARACTERS.length());
            result.append(CHARACTERS.charAt(index));
        }
        return result.toString();
    }
}
